<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "{{%svn_file}}".
 *
 * @property int $id
 * @property int $svn_id
 * @property int $file_id
 * @property string $comment 简述
 * @property string|null $detail 详述
 *
 * @property File $file
 * @property Svn $svn
 */
class SvnFile extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%svn_file}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['svn_id', 'file_id'], 'required'],
            [['svn_id', 'file_id'], 'integer'],
            [['detail'], 'string'],
            [['comment'], 'string', 'max' => 255],
            [['file_id'], 'exist', 'skipOnError' => true, 'targetClass' => File::class, 'targetAttribute' => ['file_id' => 'id']],
            [['svn_id'], 'exist', 'skipOnError' => true, 'targetClass' => Svn::class, 'targetAttribute' => ['svn_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'svn_id' => 'Svn ID',
            'file_id' => 'File ID',
            'comment' => '简述',
            'detail' => '详述',
        ];
    }

    /**
     * Gets query for [[File]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getFile()
    {
        return $this->hasOne(File::class, ['id' => 'file_id']);
    }

    /**
     * Gets query for [[Svn]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getSvn()
    {
        return $this->hasOne(Svn::class, ['id' => 'svn_id']);
    }
}
